<!--title-->
<div class="mnav1">
	<div class="m_nav">
		<div class="nav_left">
			<em class="home_icon"><?=$this->sys_name?></em><span>&nbsp;&gt;&nbsp;</span><font><?=$this->title?></font>
		</div>
	</div>
</div>

<div class="content-table2">
<div class="content-table-title"><?=$this->title?></div>
<div class="form-edit-task">

<form action="/others/add-staff-submit" method="post" name="form1" onsubmit="submitform(this);return false;" style="width: 1000px">
<div align="center"><font size="18">集团</font>&nbsp;&nbsp;&nbsp;
<input type="button" id="checkall_groups" value="全选" />
<input type="button" id="checkallNo_groups" value="全不选" />
</div>
<div align="center" style="height:500px;width:1020px;overflow:auto;border:1px solid red">
<table border="0" width="1000">
	<?php if(!empty($this->groups)):?>
	<?php $n=0;?>
	<?php foreach($this->groups as $group_id => $group_name):?>
	<?php if(!$this->my_group_id_arr[0] || in_array($group_id, $this->my_group_id_arr)):?>
	<?php if(!$n):?><tr><?php endif;?>
		<td>
		<input type="checkbox" name="group_id[]" id="group_id_<?=$group_id?>" value="<?=$group_id?>"><label for="group_id_<?=$group_id?>"> <?=$group_name?></label>
		<td>
	<?php if(2==$n):?></tr><?php endif;?>
	<?php if(2==$n){$n=0;}else{$n+=1;}?>
	<?php endif;?>
	<?php endforeach;?>
	<?php endif;?>
</table>
</div>

<br><br>

<div align="center"><font size="18">厂商</font>&nbsp;&nbsp;&nbsp;
<input type="button" id="checkall_factories" value="全选" />
<input type="button" id="checkallNo_factories" value="全不选" />
</div>
<div align="center" style="height:500px;width:1020px;overflow:auto;border:1px solid red">
<table border="0" width="1000">
	<?php if(!empty($this->factories)):?>
	<?php $n=0;?>
	<?php foreach($this->factories as $factory_id => $factory_name):?>
	<?php if(!$this->my_factory_id_arr[0] || in_array($factory_id, $this->my_factory_id_arr)):?>
	<?php if(!$n):?><tr><?php endif;?>
		<td>
		<input type="checkbox" name="factory_id[]" id="factory_id_<?=$factory_id?>" value="<?=$factory_id?>"><label for="factory_id_<?=$factory_id?>"> <?=$factory_name?></label>
		<td>
	<?php if(2==$n):?></tr><?php endif;?>
	<?php if(2==$n){$n=0;}else{$n+=1;}?>
	<?php endif;?>
	<?php endforeach;?>
	<?php endif;?>
</table>
</div>

<br><br>

<div align="center"><font size="18">地区</font>&nbsp;&nbsp;&nbsp;
<input type="button" id="checkall_cities" value="全选" />
<input type="button" id="checkallNo_cities" value="全不选" />
</div>
<div align="center" style="height:500px;width:1020px;overflow:auto;border:1px solid red">
<table border="0" width="1000">
	<?php if(!empty($this->cities)):?>
	<?php $n=0;?>
	<?php foreach($this->cities as $city_id => $city_name):?>
	<?php if(!$this->my_city_id_arr[0] || in_array($city_id, $this->my_city_id_arr)):?>
	<?php if(!$n):?><tr><?php endif;?>
		<td>
		<input type="checkbox" name="city_id[]" id="city_id_<?=$city_id?>" value="<?=$city_id?>"><label for="city_id_<?=$city_id?>"> <?=$city_name?></label>
		<td>
	<?php if(2==$n):?></tr><?php endif;?>
	<?php if(2==$n){$n=0;}else{$n+=1;}?>
	<?php endif;?>
	<?php endforeach;?>
	<?php endif;?>
</table>
</div>

<br><br>

<table border="0" width="100%">
	<tr>
		<td align="right">职位：</td>
		<td align="left">&nbsp;<input type="text" placeholder="职位" name="title" id="title" style="width: 300px"><font color="red"> *</font></td>
	</tr>
	<tr>
		<td align="right">负责人：</td>
		<td align="left"><select name="emp_id" id="emp_id">
				<option value="">【请选择】</option>
				<?php foreach($this->users as $user_id => $user_name):?>
				<option value="<?=$user_id?>"><?=$user_name?></option>
				<?php endforeach;?>
			</select><font color="red"> *</font></td>
	</tr>
	<tr>
		<td colspan="2" align="center"><br><br><input type="button" class="buttonlong" value="提交" onclick="submitform();return false;" /></td>
	</tr>
</table>
<br /><br />
</form>
</div>
<br/><br/>
</div>

<script>
<?php if($this->msg):?>
alert("<?=$this->msg?>, 信息提交失败, 请修改后再次提交。");
<?php endif;?>
	
function submitform() 
{
	
	if( document.form1.title.value.length == 0 )
	{
		alert("职位不能为空。");
		return false;
	}else if( document.form1.emp_id.value.length == 0 )
	{
		alert("负责人不能为空。");
		return false;
	}
	
	form1.submit();
}

$(document).ready(function(){
    $("#checkall_groups").click(function(){
        $("input[name='group_id[]']").each(function(){
            this.checked = true;
        });
    });
    $("#checkallNo_groups").click(function(){
        $("input[name='group_id[]']").each(function(){
            this.checked = false;
        })
    });
    $("#checkall_factories").click(function(){
        $("input[name='factory_id[]']").each(function(){
            this.checked = true;
        });
    });
    $("#checkallNo_factories").click(function(){
        $("input[name='factory_id[]']").each(function(){
            this.checked = false;
        })
    });
    $("#checkall_cities").click(function(){
        $("input[name='city_id[]']").each(function(){
            this.checked = true;
        });
    });
    $("#checkallNo_cities").click(function(){
        $("input[name='city_id[]']").each(function(){
            this.checked = false;
        })
    });
});
</script>
